package com.atguigu.edu.mapper;

import com.atguigu.edu.bean.UserChangeCtPerType;
import com.atguigu.edu.bean.UserPageCt;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserStatsMapper {
    //统计某天回流用户数 活跃用户数 新注册用户数
    @Select("SELECT 'backCt',SUM(back_ct) FROM edu.dws_user_user_login_window PARTITION par#{date}\n" +
            "UNION ALL\n" +
            "SELECT 'activeUserCt',SUM(uu_ct) FROM edu.dws_user_user_login_window PARTITION par#{date} \n" +
            "UNION ALL\n" +
            "SELECT 'newUserCt',SUM(register_ct) FROM edu.dws_user_user_register_window PARTITION par#{date}\n")
    List<UserChangeCtPerType> selectUserCt(Integer date);

    @Select("SELECT '浏览首页人数',SUM(home_view_ct) FROM dws_user_user_action_analyze_window PARTITION par#{date}\n" +
            "UNION ALL\n" +
            "SELECT '浏览详情页人数',SUM(course_detail_ct) FROM dws_user_user_action_analyze_window PARTITION par#{date}\n" +
            "UNION ALL\n" +
            "SELECT '加购物车人数',SUM(cart_ct) FROM dws_user_user_action_analyze_window PARTITION par#{date}\n" +
            "UNION ALL\n" +
            "SELECT '下单人数',SUM(order_ct) FROM dws_user_user_action_analyze_window PARTITION par#{date}\n" +
            "UNION ALL\n" +
            "SELECT '支付人数',SUM(pay_ct) FROM dws_user_user_action_analyze_window PARTITION par#{date}")
    List<UserPageCt> selectUserAnalyze(Integer date);

}
